<?php


namespace app\modules\Admin\models;

use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

class cashbackgoodsModel extends Model
{
    protected $table = 'cashback_goods';
    protected $primaryKey = 'goods_id';
    protected $appends = ['status_text'];
    protected $hidden = [];

    /**
     * @param DateTimeInterface $date
     * @return string
     */
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    public function getStatusTextAttribute()
    {
        //0=不参与,1=参与
        if ($this->attributes['status']) {
            return '参与';
        }else{
            return '不参与';
        }
    }

    public function goods()
    {
        return $this->belongsTo(\goodsModel::class, 'goods_id', 'id');
    }

}